package com.linrui.TestES;

import com.linrui.TestES.Repository.EmpRepository;
import com.linrui.TestES.doc.EmpDoc;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;

public class EStest extends BaseTest {

    @Autowired
    private ElasticsearchTemplate elasticsearchTemplate;

    @Autowired
    private EmpRepository empRepository;

    @Test
    public void testCreate() throws Exception{
        System.out.println(elasticsearchTemplate);
        elasticsearchTemplate.createIndex(EmpDoc.class);//创建索引库
        elasticsearchTemplate.putMapping(EmpDoc.class);//做定义映射

    }
    @Test
    public void testAdd(){
        EmpDoc doc = new EmpDoc(1L, "zs", 12, "he is good");
        empRepository.save(doc);
    }
}
